<?php

/**
 * Class AccountController
 */
class LogisticsController extends BaseController
{

    /*
    |--------------------------------------------------------------------------
    | 账户控制器
    |--------------------------------------------------------------------------
    |
    |
    */


    /**
     * 物流信息列表
     * @author alice
     * @date 2016-1-19
     * @return mixed
     */
    public function ShowLogisticsList()
    {
        $info = LogisticsService::instance()->ShowLogisticsList();
        return $this->view('admin.show_logistics')->with('logistics', $info);
    }

    /**
     * 添加物流线路
     * @author alice
     * @date 2016-1-19
     * @return mixed
     * @throws Exception
     */
    public function AddLogistics()
    {
        if (Request::isMethod('POST'))
        {
            #收集信息
            $aData                             = new stdClass();
            $aData->departure                  = $this->getParam('departure');
            $aData->destination                = $this->getParam('destination');
            $aData->model_type                 = $this->getParam('model_type');
            $aData->truck_length               = $this->getParam('truck_length');
            $aData->truck_weight               = $this->getParam('truck_weight');
            $aData->take_time                  = $this->getParam('take_time');
            $aData->spec_time                  = $this->getParam('spec_time');

            LogisticsService::instance()->AddLogistics($aData);
            return Redirect::to('/show_logistics');}else{
            return $this->view('admin.add_logistics');
        }
    }

    /**
     * 修改物流线路
     * @author alice
     * @date 2016-1-19
     * @return mixed
     */
    public function EditLogistics()
    {
        if (Request::isMethod('POST'))
        {
            #收集信息
            $aData                             = new stdClass();
            $aData->wl_id                      = $this->getParam('wl_id');
            $aData->departure                  = $this->getParam('departure');
            $aData->destination                = $this->getParam('destination');
            $aData->model_type                 = $this->getParam('model_type');
            $aData->truck_length               = $this->getParam('truck_length');
            $aData->truck_weight               = $this->getParam('truck_weight');
            $aData->take_time                  = $this->getParam('take_time');
            $aData->spec_time                  = $this->getParam('spec_time');

            LogisticsService::instance()->EditLogistics($aData);
            return Redirect::to('/show_logistics');}else{
            $id = $this->getParam('wl_id');
            $info = LogisticsService::instance()->ShowLogisticsInfo($id);
            return $this->view('admin.edit_logistics')->with('logistics',$info);
        }
    }

}